home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Health Monitor 2.1 / HealthMonitor.msi / _A9A458837CEAFF9D55B2EAE342FFA8DF / _3BC394679EF84C06B74ECFCF6140BF3C < prev    next >
Encoding:
Text File  |  2005-01-03  |  1.2 KB  |  45 lines

  1. ' ***************************************************************
  2. ' * GetHTTP.vbs                                 *
  3. ' * By Vittorio Pavesi (www.vittorio.tk)              *
  4. ' *                                * 
  5. ' * Simulate an HTTP Get and return time information           *
  6. ' ***************************************************************
  7.  
  8. CheckHost("http://www.vittorio.tk")
  9.  
  10. Sub CheckHost(host)
  11.     dim startdate
  12.     Dim objXmlHttp
  13.     Dim strHTML
  14.     Set objXmlHttp = CreateObject("Msxml2.ServerXMLHTTP")
  15.  
  16.     lResolve = 1 * 1000
  17.     lConnect = 5 * 1000
  18.     lSend = 10 * 1000
  19.     lReceive = 10 * 1000
  20.  
  21.     objXmlHttp.setTimeouts lResolve, lConnect, lSend, lReceive
  22.  
  23.     startdate = now
  24.     t1 = timer
  25.     objXmlHttp.open "GET", host , False
  26.     objXmlHttp.send
  27.  
  28.     if Err.number = 0 and objXmlHttp.status = 200 then
  29.       Result = "OK"
  30.       'objXmlHttp.responseText
  31.     else
  32.       Result = "Error"
  33.     end if
  34.     t2 = timer
  35.     Set objXmlHttp = Nothing
  36.     wscript.echo "Host: " & host & vbcrlf & "StartTime: " & startdate & vbcrlf & "Result: " & Result & vbcrlf & "Response Time: " & TimeDiff(t2,t1) & "msec"
  37. End sub
  38.  
  39. Function TimeDiff(iEnd, iStart)
  40.     ' returns time diff in milliseconds
  41.     Dim iReturn
  42.     iReturn = iEnd - iStart
  43.     If iReturn < 0 Then iReturn = iEnd - iStart + (60*60*24)
  44.     TimeDiff = 1000 * iReturn
  45. End Function